﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using CI.Models.Data;

namespace ModelPerformance
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            LoadModels(new Action[] {Production});
        }

        private static void Production()
        {
            var r = new XmlDataRepository<Item>("Production.xml");

            r.Load();

            Console.WriteLine(r.All.Count());

            dynamic bloodclaw = r.All.Where(i => i.typeName == "Bloodclaw Light Missile").FirstOrDefault();

            Console.WriteLine("{0} comes in portions of {1}",bloodclaw.typeName,bloodclaw.portionSize);

        }

        public static void LoadModels(IEnumerable<Action> models)
        {
            foreach (var model in models)
            {
                Console.WriteLine("Loading " + model.Method.Name);
                var sw = new Stopwatch();
                sw.Start();
                model.Invoke();
                sw.Stop();
                Console.WriteLine("Load took : {0} seconds", sw.Elapsed.TotalSeconds);
            }
        }
    }
}